Skip to content

Fix Android finalize deprecation warning#8

Merged
AlexeyBuryanov merged 2 commits into
developfrom
copilot/fix-finalize-deprecation-warning
Apr 30, 2026
Merged

Fix Android finalize deprecation warning#8
AlexeyBuryanov merged 2 commits into
developfrom
copilot/fix-finalize-deprecation-warning

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 30, 2026

Summary

  • remove the JavaFinalize override from SelfDisposingBitmapDrawable
  • keep the existing Dispose(bool) cleanup order so cleanup behavior stays unchanged
  • stop .NET for Android from generating the deprecated Java finalize() stub for this drawable

Validation

  • dotnet restore source/FFImageLoading.Droid/FFImageLoading.Droid.csproj
  • dotnet build source/FFImageLoading.Droid/FFImageLoading.Droid.csproj -c Debug --no-restore
  • parallel_validation (Code Review + CodeQL)

Notes

  • the Android project still has pre-existing nullable/obsolete warnings unrelated to this change, but the SelfDisposingBitmapDrawable.java finalize() removal warning is no longer emitted in the Android build output.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the JavaFinalize() override from the Android SelfDisposingBitmapDrawable to eliminate the deprecated Java finalize() stub that .NET for Android would otherwise generate, while keeping the existing Dispose(bool) cleanup order intact.

Changes:

  • Removed the JavaFinalize() override from SelfDisposingBitmapDrawable.
  • Preserved the Dispose(bool) behavior (calling SetNoLongerDisplayed() after base.Dispose(disposing)), keeping cleanup behavior consistent.

@AlexeyBuryanov
Copy link
Copy Markdown
Owner

@copilot are you sure it's won't break anything?

Copy link
Copy Markdown
Author

Copilot AI commented Apr 30, 2026

@copilot are you sure it's won't break anything?

I’m confident for the library’s intended lifecycle. The removed method was only the Java finalize() hook; it did not contain unique cleanup logic beyond SetNoLongerDisplayed(), and that still runs from Dispose(bool) in 8538883, which is the normal path when the drawable is released by the view/cache. I also rebuilt the Android project again and confirmed the SelfDisposingBitmapDrawable.java finalize() warning is gone with no new build errors. If you want extra safety, I can add a focused regression check around drawable disposal behavior.

@AlexeyBuryanov AlexeyBuryanov merged commit 5662603 into develop Apr 30, 2026
5 checks passed
@AlexeyBuryanov AlexeyBuryanov deleted the copilot/fix-finalize-deprecation-warning branch April 30, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants